import {recommendActionType} from "./recommendaction";
export interface recommendState{
    productList:any[],
    isloading:boolean,
    error:null|string
}
const defaultState:recommendState={
    productList:[],
    isloading:true,
    error:null
}
export default (state=defaultState,action:recommendActionType)=>{
    switch (action.type){
        case "REQUEST_RECOMMEND_SUCCESS":
            return {...state,productList:action.payload,isloading:false}
        case "REQUEST_RECOMMEND_LOADING":
            return {...state,isloading: true}
        case "REQUEST_RECOMMEND_FAIL":
            return {...state,isloading:false,error: action.payload}
        default:
            return state
    }
}